﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinANLI
{
    public partial class Form1 : Form
    {
            public static string name;
            public static string pwd;
        public Form1()
        {
            name = "zh";
            pwd = "123";
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            this.textBox1.Text = null;
            this.textBox2.Text = null;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text=="zs"&&textBox2.Text=="123")
            {
                MessageBox.Show("登录成功！");
                student stu = new student();
                stu.ShowDialog();
            }
            else
            {
                MessageBox.Show("用户名或密码不正确！");
            }


        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.textBox1.Text = null;
            this.textBox2.Text = null;
            this.label3.BackColor = Color.Transparent;
            this.label4.BackColor = Color.Transparent;

        }



        private void textBox1_MouseLeave_1(object sender, EventArgs e)
        {
            var username = this.textBox1.Text;

            if (username == "")
            {
                //MessageBox.Show("用户名不能为空");
                this.label3.Text = "用户名不能为空";
            }
            else
            {
                this.label3.Text = "";
            }
        }


        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_MouseLeave(object sender, EventArgs e)
        {
            var userpwd = this.textBox1.Text;
            if (userpwd == "")
            {
                //MessageBox.Show("密码不能为空");
                this.label4.Text = "密码不能为空";
            }
            else
            {
                this.label4.Text = "";
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text=="")
            {
                
            }
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                button1_Click(sender,e);
            }
        }
    }
}
